package com.example.demo.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.example.demo.mapper.ExamRuleMapper;
import com.example.demo.mapper.ExamTkCnApiMapper;
import com.example.demo.mapper.ExamTkCnMapper;
import com.example.demo.model.ExamRule;
import com.example.demo.model.ExamTkCn;
import com.example.demo.modelApi.ExamTkCnApi;
@Service
public class ExamTkCnApiService {

	@Autowired
	private ExamTkCnApiMapper examTkCnApiMapper;
	
	public List<ExamTkCnApi> selectExamTkCn(Integer car, Integer course, Integer type, Integer single, Integer doubles, Integer opinion){
        String driverType = null;
        String requestType = type.toString();
        String courseStr = course.toString();
        String singleType = "2";
        String doublesType = "3";
        String opinionType = "1";
		if(3 == car) {
			driverType = "A2B2";
        } else if(2 == car) {
        	driverType = "A3B1";
        }else if(1 == car) {
        	driverType = "C1";
        }else {
        	driverType = "DEF";
        }	
		List<ExamTkCnApi> examTkCnApis = examTkCnApiMapper.getExamTkCnApis(courseStr, driverType, requestType, singleType, single);
		List<ExamTkCnApi> examTkCnApis2 = examTkCnApiMapper.getExamTkCnApis(courseStr, driverType, requestType, doublesType, doubles);
		List<ExamTkCnApi> examTkCnApis3 = examTkCnApiMapper.getExamTkCnApis(courseStr, driverType, requestType, opinionType, opinion);
        
		for(int i = 0;  i<examTkCnApis2.size(); i++) {
			examTkCnApis.add(examTkCnApis2.get(i));
		}
		for(int i = 0;  i<examTkCnApis3.size(); i++) {
			examTkCnApis.add(examTkCnApis3.get(i));
		}
		
		return examTkCnApis;
    }
}
